<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.9.0.min.js"></script>
</head>
<body>
<input><button>添加</button><a href="#">查看</a>
<ul>
</ul>
</body>
</html>
<script>
    $(function () {
        var index=0;
        $("button").click(function(){
            var value=$("input").val();
            if(window.localStorage){
                var storage=window.localStorage;
                storage.setItem(index+"",value);
                ++index;
            }
        })

        $("a").click(function () {
            var storge=window.localStorage;
            for(var i=0;i<storge.length;++i){
                var key=storge.key(i);
                $("ul").append("<li id="+key+">"+key+","+storge.getItem(key)+"</li>");
            }
        })

        $("ul").on("click","li", function () {
            var key=$(this).attr("id");
            if(window.confirm()){
                $(this).remove();
                var storage=window.localStorage;
                storage.removeItem(key);
            }
        })
    })
</script>